package com.cheyun.netsalev3.viewmodel.orderquanyi

import android.content.Intent
import android.os.Looper
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.ObservableField
import androidx.lifecycle.MutableLiveData
import com.cheyun.netsalev3.R
import com.cheyun.netsalev3.bean.aftersale.MaintenanceDetail
import com.cheyun.netsalev3.bean.basedata.Member
import com.cheyun.netsalev3.bean.orderquanyi.OrderquanyiDetail
import com.cheyun.netsalev3.repository.aftersale.MaintenanceDetailsRepository
import com.cheyun.netsalev3.repository.orderquanyi.OrderquanyiDetailsRepository
import com.cheyun.netsalev3.utils.FunctionUtils
import com.cheyun.netsalev3.utils.MySharedPreferences
import com.cheyun.netsalev3.utils.ToastUtil
import com.cheyun.netsalev3.view.aftersale.EditMaintenanceActivity
import com.cheyun.netsalev3.viewmodel.BaseViewModel
import com.cheyun.netsalev3.widget.MyContentDialog
import com.cheyun.netsalev3.widget.MyDialog
import com.jeremyliao.liveeventbus.LiveEventBus
import java.io.Serializable

/**
 * @author Michael
 * @date  2018/12/19 - 9:41.
 */
class OrderquanyiDetailsActivityViewModel(var maintenanceDetailsRepository: OrderquanyiDetailsRepository) : BaseViewModel() {

    var detail = ObservableField<OrderquanyiDetail>()
    var maintenanceData:OrderquanyiDetail? = null

    var phoneMsg = MutableLiveData<String>()
    var state = MutableLiveData<Int>()

    var memberlist = ArrayList<Member>()

    init {
        initData()

        MySharedPreferences.getBaseData()?.member?.apply {
            memberlist.addAll(this)
        }
    }

    /**
     * 初始化数据
     */
    fun initData() {
        maintenanceDetailsRepository.getData(this::setData)

    }

    private fun setData(item: OrderquanyiDetail) {
        detail.set(item)
        maintenanceData = item

        phoneMsg.postValue(item.phone)
        state.postValue(item.award_state_key.toInt())
    }

}